﻿using System;
using System.Drawing;
using Alchemi.Core.Owner;

namespace GridRayTracer
{
  [Serializable]
  public class GridRayTracerThread : GThread
  {
    public GridRayTracerThread(Rectangle roi, RayTracer rayTracer)
    {
      Roi = roi;
      this.rayTracer = rayTracer;
      image = new Bitmap(roi.Width, roi.Height);      
    }

    public Bitmap Image 
    { 
      get 
      { 
        return image;
      }
    }

    public Rectangle Roi 
    {
      get
      {
        return roi;
      }
      set
      {
        roi = value;
      }
    }

    public override void Start()
    {
      for (int y = roi.Top; y < roi.Bottom; ++y)
        for (int x = roi.Left; x < roi.Right; ++x) 
          image.SetPixel(x - roi.Left, y - roi.Top, rayTracer.GetColorAt(x, y));
    }

    private Bitmap image;
    private Rectangle roi;
    private RayTracer rayTracer;
  }
}
